<?php
namespace app\admin\controller;
use think\Controller;

class Featured extends Base  //控制器层
{
    //构造函数 私有属性
	private $obj;
	public function _initialize(){
		$this->obj = model("Featured");
		}

	
	
    public function index()
    {
        
		
		
		
		//获取推荐位类别
		$types = config('featured.featured_type');
		//获取列表数据
		$type = input('get.type', '0', 'intval');
		// var_dump($type);
		$featureds = $this->obj->getFeaturedsByType($type);
		//halt($featureds);
		return $this->fetch('',[
		   'types' => $types,
		   'featureds' => $featureds,
		   'type' => $type,
		
		]);

	}
	
			
	

	public function add()
    {
        
		
		if(request()->isPost()){
			$data = input('post.');
			//数据校验
			
			//shujuruke
			$id = model('Featured')->add($data);
			if($id){
				$this->success('添加成功');
				}else{
					$this->error('添加失败');
					}
			
			}else{
		$types = config('featured.featured_type');
		return $this->fetch('',[
		   'types' => $types,
		
		]);

			}

	}
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
}
?>